package com.hongyi.modelcontest.modular.wechat.vo;

import com.alibaba.fastjson.JSONObject;
import com.hongyi.modelcontest.core.util.HttpClientUtil;
import com.hongyi.modelcontest.modular.wechat.service.WxTokenService;

import javax.annotation.Resource;

public class WxSengMsg {
    @Resource
    private WxTokenService wxTokenService;

    /**
     * 发送消息
     *
     * @param wxMsg 要发送的信息
     * @throws Exception 发送信息异常
     */
    public static void sendMessage(WxMsg wxMsg, String baseToken) throws Exception {
        String url = "https://api.weixin.qq.com/cgi-bin/message/template/send?" +
                "access_token=" + baseToken;
        HttpClientUtil.sendJSONHttpPost(url, JSONObject.toJSONString(wxMsg));
    }
}
